﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using NLog;

namespace NGinnBPM.Engine.WindsorHost
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                //NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging();
                Console.WriteLine("Hit Enter to start");
                Console.ReadLine();
                Debug();
                return;
            }
            ServiceBase[] ServicesToRun;

            // More than one user Service may run within the same process. To add
            // another service to this process, change the following line to
            // create a second service object. For example,
            //
            //   ServicesToRun = new ServiceBase[] {new Service1(), new MySecondUserService()};
            //
            ServicesToRun = new ServiceBase[] { new WindsorHostService() };

            ServiceBase.Run(ServicesToRun);
        }

        static void Debug()
        {
            //NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging(NLog.LogLevel.Trace);
            try
            {
                WindsorHostService ws = new WindsorHostService();
                ws.Start();
                //srv.Start();
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error("Error: {0}", ex);
            }
            System.Console.ReadLine();
        }

        static void Test()
        {

        }
    }
}
